﻿using B.S.Base.Read.API.Application.Command;
using MediatR;
using WEBAPI.Damoin;
using WEBAPI.ErroeCode;
using WEBAPI.Indaseture.Infasetures;

namespace B.S.Base.Read.API.Application.CommandHandLer
{
    public class GetDeptmodelCommandHandLer : IRequestHandler<GetDeptmodelCommand, APIResult<List<DeptModel>>>
    {

        IBaseRepostiy<DeptModel> _menuModel;

        public GetDeptmodelCommandHandLer(IBaseRepostiy<DeptModel> menuModel)
        {
            _menuModel = menuModel;
        }
        public async Task<APIResult<List<DeptModel>>> Handle(GetDeptmodelCommand request, CancellationToken cancellationToken)
        {
           var list=_menuModel.GetAll();
            return new APIResult<List<DeptModel>>
            {
                Code = ResultCode.Ok,
                Data = list.ToList(),
                Message = "获取成功"
            };
        }
    }
}
